package com.candy.databasedocuments.service;

import com.candy.databasedocuments.entity.DatabaseConfig;
import com.candy.databasedocuments.entity.Table;
import com.candy.databasedocuments.utils.ToolsUtils;
import org.apache.commons.io.FileUtils;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/7/7 11:12
 * @Description 文档转换抽象类
 */
public abstract class AbstractDocumentService implements DocumentService {

    @Resource
    public DatabaseConfig databaseConfig;

    @Override
    public String tableToDocument(List<Table> tableList) throws Exception {
        return null;
    }

    protected File createFile(String fileSuffix) throws IOException {
        File dir = new File(databaseConfig.getDcAttr().getPath());
        FileUtils.forceMkdir(dir);
        File file = new File(dir, ToolsUtils.getFileName(fileSuffix));
        return file;
    }

}
